<?php

class ActionContact extends BaseAction
{
    public function run()
    {
        $isContactSended = false;
        $oContact        = new Contact();
        
        if ( Yii::app()->request->getIsPostRequest() )
        {
            $oContact->setAttributesFromRequest('aContact');
            $oContact->contact_cdate = time();
            if ( $oContact->save() )
            {
                $oEmailNotification = new EmailNotification();
                $oEmailNotification->sendEmailToAdminFromContactForm($oContact);
                
                $isContactSended = true;
            }
        }
        
        $this->template->isContactSended = $isContactSended;
        $this->template->oContact        = $oContact;
    }
}